/**
 * 
 */
package com.eshopper.product.service;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.eshopper.product.model.Product;
import com.eshopper.product.repository.jpa.ProductRepository;

/**
 * @author Arun Kumar, Nov 19, 2014
 *
 */
@Service
@Transactional
public class ProductServiceImpl implements ProductService {
	
	private static final Logger LOGGER = LoggerFactory.getLogger(ProductServiceImpl.class);

    @Resource
    private ProductRepository repository;

    @Resource
    private ProductIndexService indexService;
    
	/*(non-Javadoc) 
	 * @see
	 * com.eshopper.product.service.ProductService#addProduct(com.eshopper.product.model.Product)
	 */
	@Override
	public Product addProduct(Product product) {

		LOGGER.info("Adding a new product entry with information: {}", product);

		Product persisted = repository.save(product);
		indexService.addToIndex(persisted);

		return persisted;

	}

	/* (non-Javadoc)
	 * @see com.eshopper.product.service.ProductService#updateProduct(com.eshopper.product.model.Product)
	 */
	@Override
	public Product updateProduct(Product product) {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see com.eshopper.product.service.ProductService#getProducts()
	 */
	@Override
	public List<Product> getProducts() {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see com.eshopper.product.service.ProductService#deleteProduct(java.lang.Long)
	 */
	@Override
	public void deleteProduct(Long productId) {
		// TODO Auto-generated method stub
		
	}

	/* (non-Javadoc)
	 * @see com.eshopper.product.service.ProductService#getProduct(java.lang.String)
	 */
	@Override
	public Product getProduct(Long productId) {
		// TODO Auto-generated method stub
		return null;
	}
 
}
